<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link href="./bootstrap/css/bootstrap.css" rel="stylesheet" type="text/css">
    <script src="https://s3.pstatp.com/cdn/expire-1-M/jquery/3.1.1/jquery.min.js"></script>
    <script src="./bootstrap/js/bootstrap.js"></script>
    <script>
        function subInfo(){
            //获取所有的提交资料
            let mcontact = document.getElementById("inputmcontact").value;
            let mphone = document.getElementById("inputmphone").value;
            let memail = document.getElementById("inputmemail").value;
            let maddress = document.getElementById("inputmaddress").value;
            let merchantType = document.getElementById("inputmerchantType").value;
            let mrealName = document.getElementById("inputmrealName").value;
            let midCard = document.getElementById("inputmidCard").value;
            let midCardImg = document.getElementById("inputmidCardImg").value;
            //判断以上所有数据是否为空
            if (mcontact === '' || mphone === '' || memail === '' || maddress === '' || merchantType === '' || mrealName === '' || midCard === '' || midCardImg === '') {
                //提示用户
                document.getElementById("tipShow").innerHTML = "请填写完整信息....";

            }else {
                document.getElementById("tipShow").innerHTML = "";
                let obj = {mcontact:mcontact, mphone:mphone, memail:memail, maddress:maddress, merchantType:merchantType, mrealName:mrealName, midCard:midCard, midCardImg:midCardImg}
                //提交数据
                $.ajax({
                    type:"POST",
                    url: "merchant/update",
                    contentType:"application/json", //前 -> 后
                    dataType:"json",//后 ->前
                    data: JSON.stringify(obj),
                    success:function (data) {
                        //提示用户
                        if (data.code === 200) {
                            document.getElementById("tipShow").innerHTML = "资料提交成功，请耐心等待平台审核..."


                        }else {
                            document.getElementById("tipShow").innerHTML = "资料提交失败，请重试..."
                        }
                    },
                    complete: function (res) {
                        console.log('请求失败，', res)
                    }
                })
            }

        }
    </script>

</head>
<body>
<div style="height: 50px">
    <span id="tipShow" style="color:red"></span>
</div>


<form class="form-horizontal">
    <div class="form-group">
        <label for="inputmcontact" class="col-sm-2 control-label">商家联系人</label>
        <div class="col-sm-8">
            <input type="text" class="form-control" id="inputmcontact" placeholder="请输入商家联系人">
        </div>
    </div>
    <div class="form-group">
        <label for="inputmphone" class="col-sm-2 control-label">联系方式</label>
        <div class="col-sm-8">
            <input type="text" class="form-control" id="inputmphone" placeholder="请输入商家联系方式">
        </div>
    </div>
    <div class="form-group">
        <label for="inputmemail" class="col-sm-2 control-label">联系邮箱</label>
        <div class="col-sm-8">
            <input type="text" class="form-control" id="inputmemail" placeholder="请输入商家邮箱">
        </div>
    </div>
    <div class="form-group">
        <label for="inputmaddress" class="col-sm-2 control-label">联系地址</label>
        <div class="col-sm-8">
            <input type="text" class="form-control" id="inputmaddress" placeholder="请输入商家地址">
        </div>
    </div>
    <div class="form-group">
        <label for="inputmerchantType" class="col-sm-2 control-label">商家类型</label>
        <div class="col-sm-8">
            <select class="form-control" id="inputmerchantType">
                <option value="0">个人</option>
                <option value="1">企业</option>
            </select>
        </div>
    </div>
    <div class="form-group">
        <label for="inputmrealName" class="col-sm-2 control-label">商家真实名称</label>
        <div class="col-sm-8">
            <input type="text" class="form-control" id="inputmrealName" placeholder="请输入商家真实名称">
        </div>
    </div>
    <div class="form-group">
        <label for="inputmidCard" class="col-sm-2 control-label">商家证件号</label>
        <div class="col-sm-8">
            <input type="text" class="form-control" id="inputmidCard" placeholder="请输入商家证件号">
        </div>
    </div>
    <div class="form-group">
        <label for="inputmidCardImg" class="col-sm-2 control-label">商家证件图</label>
        <div class="col-sm-8">
            <input type="file" id="inputmidCardImg">
        </div>
    </div>
</form>
<button class="btn btn-success" onclick="subInfo()" type="button">提交</button>
</body>
</html>